﻿using System;
using System.Collections.Generic;
using System.Text;

namespace YouHP.Utility
{
    public class TinyMCE
    {
        public static string Path
        {
            get 
            {
                return "/Support/TinyMCE/tiny_mce.js";
            }
        }

        public static string InitSimple(string elem)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("tinyMCE.init({ \r\n");
            sb.Append("mode : \"exact\", \r\n");
	        sb.Append("theme : \"advanced\", \r\n");
            sb.Append("skin : \"o2k7\", \r\n");
            sb.AppendFormat("elements : \"{0}\", \r\n",elem);

            sb.Append("plugins : \"searchreplace,advlink,advimage,media,insertdatetime,preview,advhr,print,fullscreen,contextmenu\", \r\n");
            sb.Append("language: \"zh\", \r\n");
            sb.Append("\r\n");
            sb.Append("theme_advanced_buttons1 : \"bold,italic,underline,separator,bullist,numlist,separator,outdent,indent,separator,image,forecolor,backcolor,separator,formatselect,fontsizeselect,preview\",\r\n");
            sb.Append("theme_advanced_buttons2 : \"\", \r\n");
            sb.Append("theme_advanced_buttons3 : \"\", \r\n");
            sb.Append("theme_advanced_toolbar_location : \"top\", \r\n");
            sb.Append("theme_advanced_toolbar_align : \"left\", \r\n");
            sb.Append("theme_advanced_path_location : \"bottom\", \r\n");
            sb.Append("theme_advanced_resizing : true, \r\n");
            sb.Append("extended_valid_elements : \"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]\"");
            sb.Append("   }); \r\n");
            return sb.ToString();
        }

        public static string InitAdvance(string elem)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("tinyMCE.init({ \r\n");
            sb.Append("mode : \"exact\", \r\n");
            sb.Append("theme : \"advanced\", \r\n");
            sb.Append("skin : \"o2k7\", \r\n");
            sb.AppendFormat("elements : \"{0}\", \r\n", elem);
            sb.Append("plugins : \"safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template\", \r\n");
            sb.Append("language: \"zh\", \r\n");
            sb.Append("\r\n");
            sb.Append("theme_advanced_buttons1 : \"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect\",\r\n");
            sb.Append("theme_advanced_buttons2 : \"cut,copy,paste,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,|,insertdate,inserttime,|,forecolor,backcolor\", \r\n");
            sb.Append("theme_advanced_buttons3 : \"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl\", \r\n");
            sb.Append("theme_advanced_buttons3 : \"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,|,preview,code\", \r\n");
            sb.Append("theme_advanced_toolbar_location : \"top\", \r\n");
            sb.Append("theme_advanced_toolbar_align : \"left\", \r\n");
            sb.Append("theme_advanced_path_location : \"bottom\", \r\n");
            sb.Append("theme_advanced_resizing : true, \r\n");
            sb.Append("theme_advanced_resize_horizontal : false, \r\n");
            sb.Append("extended_valid_elements : \"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]\"");
            sb.Append("   }); \r\n");
            return sb.ToString();
        }
    }
}
